fix(dynamo-gen): use robust DateTime check in UnixTimestampTypeHandler#78
Conversation
UnixTimestampTypeHandler.CanHandle still gated on brittle name-only comparisons (underlyingType.Name == nameof(DateTime)/DateTimeOffset) while AttributeHandlerRegistry already moved to a symbol-based check. Extract that check into a shared ITypeSymbol.IsDateTimeOrDateTimeOffset extension (SpecialType for DateTime, name + System namespace for DateTimeOffset) and use it in both places, so a user-defined type named DateTime outside System is no longer mistaken for the BCL type. Adds a regression test covering the spoofed-type case.
|
Warning Review limit reached
More reviews will be available in 33 minutes and 17 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Context
Follow-up to #74. That PR moved
AttributeHandlerRegistryto a robust, symbol-based DateTime/DateTimeOffset check, butUnixTimestampTypeHandler.CanHandlewas left on the brittle name-only comparison:A user-defined type named
DateTime(orDateTimeOffset) outside theSystemnamespace would be mistaken for the BCL type.Change
ITypeSymbol.IsDateTimeOrDateTimeOffset()extension (SpecialType.System_DateTimeforDateTime; type name +Systemnamespace viaToDisplayString()forDateTimeOffset, which has noSpecialType).UnixTimestampTypeHandler.CanHandleandAttributeHandlerRegistry— single source of truth, removes the duplicated namespace logic.Scope notes
Deliberately left untouched (out of scope of this finding):
UnixTimestampTypeHandler.GenerateFromDynamoRecordname checks — they run only afterCanHandlealready confirmed the type, so they select a branch rather than gate.DateTimeTypeHandler/UnixTimestampAttributeHandlername-only checks — pre-existing, unrelated to this finding. The new extension is available to tighten them later.Validation
dotnet buildof the generator: clean (0 warnings/errors).dotnet test: 359 passed, 0 failed — including a new regression test that builds a type namedDateTimeoutsideSystemand assertsCanHandlereturnsfalse(would have returnedtrueunder the old check).